# -*- coding: utf-8 -*-

from matplotlib import pyplot

from ..widgets import widget

class plain_chart(widget):
	'''
	平面图基类
	'''

	pass

class pie_chart(plain_chart):
	'''百分比饼图'''
	def __init__(self,figure_full_filename,data_with_one_dimension):
		super(pie_chart, self).__init__()
		current_figure=pyplot.figure()
		pie_plot=data_with_one_dimension.plot(kind='pie', autopct='%.2f')
		current_figure.add_subplot(pie_plot)
		current_figure.tight_layout()
		figure_full_filename+='_pie_chart.png'
		current_figure.savefig(figure_full_filename)
		pass
	pass

class bar_chart(plain_chart):
	'''
	条形图
	'''
	def __init__(self,figure_full_filename,data_with_one_dimension):
		super(bar_chart, self).__init__()

		current_figure=pyplot.figure()
		bar_plot=data_with_one_dimension.plot(kind='bar')
		self.axes_annotate_patching(bar_plot)
		current_figure.add_subplot(bar_plot)
		current_figure.tight_layout()
		figure_full_filename+='_bar_chart.png'
		current_figure.savefig(figure_full_filename)
		pass
	pass

